use rbatis::{crud, impled, py_sql};
use rbatis::executor::Executor;
use crate::domain::entity::biz_entity::BizEntity;

/// UserEntity 基础查询
crud!(BizEntity {}, "api_biz");

/// count_by_name 统计业务先名称是否存在
#[py_sql("`select count(1) from api_biz as t where t.biz_name=#{name}`")]
pub async fn count_by_name(rb: &mut dyn Executor, name: &str) -> rbatis::Result<u64> {
    impled!()
}

#[py_sql("`select count(1) from api_biz as t where t.biz_name=#{name} and t.id != #{id}`")]
pub async fn count_by_name_and_not_id(rb: &mut dyn Executor, id: u64, name: &str) -> rbatis::Result<u64> {
    impled!()
}

/// select_biz_page 分页查询
#[py_sql("`select t.id, t.biz_name, t.biz_order from api_biz as t where 1 = 1`
           if name != '':
               `and t.biz_name=#{name}`
          `order by t.biz_order`
          `asc limit #{page_size} offset #{page_num}`")]
pub async fn select_biz_page(rb: &mut dyn Executor,
                              page_num:u64,
                              page_size:u64,
                              name:Option<String>)
                              -> rbatis::Result<Vec<BizEntity>>{
    impled!()
}

/// select_biz_count 统计查询
#[py_sql("`select count(1) from api_biz as t where 1 = 1`
           if name != '':
               `and t.biz_name=#{name}`")]
pub async fn select_biz_count(rb: &mut dyn Executor, name:Option<String>) -> rbatis::Result<u64>{
    impled!()
}

#[py_sql("`select count(1) from api_biz")]
pub async fn count_by_id(rb: &mut dyn Executor) -> rbatis::Result<u64> {
    impled!()
}